home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / northc / northc1.lzh / include / macros.h < prev    next >
C/C++ Source or Header  |  1990-08-30  |  649b  |  27 lines

  1. /*
  2.  *    MACROS.H    commonly useful macros
  3.  */
  4.  
  5. #ifndef    MACROS_H
  6. #define    MACROS_H
  7.  
  8. /* absolute value for any type of number */
  9. #define    abs(x)        ((x)<0?(-(x)):(x))
  10.  
  11. /* maximum and minumum for any type of number */
  12. #define max(x,y)       (((x)>(y))?(x):(y))
  13. #define    min(x,y)       (((x)<(y))?(x):(y))
  14.  
  15. /* swap any objects which can be XORed */
  16. #define    swap(a,b)    ((a)=(a)^((b)=(b)^((a)=(a)^(b))))
  17.  
  18. /* lo and hi byte of a word */
  19. #define    lobyte(x)    (((unsigned char *)&(x))[1])
  20. #define    hibyte(x)    (((unsigned char *)&(x))[0])
  21.  
  22. /* lo and hi word of a long */
  23. #define    loword(x)    (((unsigned int *)&(x))[1])
  24. #define    hiword(x)    (((unsigned int *)&(x))[0])
  25.  
  26. #endif MACROS_H
  27.